﻿<html xmlns:color="http://www.w3.org/1999/xhtml">
<head>
	<!-- 页面meta -->
	<meta charset="utf-8">
	<meta http-equiv="Content-Type" content="IE=edge">
	<title>随访组分组管理</title>
	<!-- Tell the browser to be responsive to screen width -->
	<meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
	<link rel="stylesheet" href="../static/plugins/bootstrap/css/bootstrap.min.css">
	<link rel="stylesheet" href="../static/plugins/adminLTE/css/AdminLTE.css">
	<link rel="stylesheet" href="../static/plugins/adminLTE/css/skins/_all-skins.min.css">
	<link rel="stylesheet" href="../static/css/style.css">
	<link rel="stylesheet" href="../static/plugins/angularjs/toaster.min.css">
	<script src="../static/plugins/jQuery/jquery-2.2.3.min.js"></script>
	<script src="../static/plugins/bootstrap/js/bootstrap.min.js"></script>

	<script type="text/javascript" src="../static/plugins/angularjs/angular.min.js"></script>
	<script type="text/javascript" src="../static/plugins/angularjs/angular-animate.min.js"></script>
	<script type="text/javascript" src="../static/plugins/angularjs/toaster.min.js"></script>

	<style>
		.tab{
			margin-left:300px;
		}
		.box-body{
			text-align:left;
		}
		.top{
			float: right;
			padding-right: 230px;
		}
		#update{
			background-color: #00BFFF;
			color:#FFFFFF;
		}
	</style>

	<script type="text/javascript">
        var app = angular.module("TbFollowVO",[]);
        app.controller("TbFollowVOController",function ($scope,$http) {
            $scope.model = {
                "id": "",
                "principal": "",
                "state": "",
                "createTime": "",
                "hospitalId":"",
                "hospital":"",
                "departmentId":"",
                "departmentName":"",
                "levelId":"",
                "level":"",
                "followId":"",
                "followName":"",
                "groupId":"",
                "groupClass":"",
                "phone":"",
                "startTime":"",
                "endTime":"",
                "classNumber":"",
                "patientAmount":"",
                "backGround":""
            };
            $scope.pages = function (pageNum,pageSize) {
                if (pageNum == null || pageNum == "") {
                    pageNum=$("#pagenum").val();
                }
                if (pageSize == null || pageSize==""){
                    var myselect=document.getElementById("pageSize");
                    var index = myselect.selectedIndex;
                    var optionsval = myselect.options[index].value;
                    pageSize=optionsval;
                }
                $scope.model.pageNum = pageNum;
                $scope.model.pageSize = pageSize;
                $http({
                    url: "selectFollowAll",
                    method: "post",
                    data: $scope.model,
                    dataType: "json",
                    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                    transformRequest: function (obj) { //在请求之前对data传参进行格式转换
                        var str = [];
                        for (var p in obj) {
                            str.push(p + "=" + obj[p]);
                        }
                        return str.join("&");
                    }
                }).success(function (data) {//请求成功并返回数据
                    $scope.pageUtil = data;
                })
            }
            $scope.addGroup = function () {
                $http({
                    url:"addGroup",
                    method:"post",
                    data:$scope.model,
                    headers:{ 'Content-Type': 'application/x-www-form-urlencoded'},
                    transformRequest: function (obj) { //在请求之前对data传参进行格式转换
                        var str = [];
                        for (var p in obj) {
                            str.push(p + "=" + obj[p]);
                        }
                        return str.join("&");
                    }
                }).success(function (data) {//请求成功并返回数据
                    $scope.pageUtil = data;
                })
            }
        });
        $(function () {
            $.ajax({
                url:'selectDepartment',
                type:"post",
                dataType:"json",
				//成功返回数据集合List
                success:function (list) {
                    //定义空字符串
                    var s = '';
                    //遍历循环数组中的数据
                    for (var i=0;i<list.length;i++){
                    //拼接<option value="list[i].departmentId">"+list[i].departmentName+"</option>
                        s+="<option value = '"+list[i].departmentId+"'>"+list[i].departmentName+"</option>"
                    }
                    //拼接s
                    $("#departmentId,#departmentId2").append(s);
                }
            })
        })
        $(function () {
            $.ajax({
                url:"selectLevel",
                type:"post",
                dataType:"json",
                success:function (list) {
                    var s = "";
                    for(var i = 0;i<list.length;i++){
                        s+="<option value='"+list[i].levelId+"'>"+list[i].level+"</option>"
                    }
                    $("#levelId").append(s);
                }
            })
        })
        $(function () {
            $.ajax({
                url:'selectHospital',
                type:"post",
                dataType:"json",
                //成功返回数据集合List
                success:function (list) {
                    //定义空字符串
                    var s = '';
                    //遍历循环数组中的数据
                    for (var i=0;i<list.length;i++){
                        //拼接<option value="list[i].departmentId">"+list[i].departmentName+"</option>
                        s+="<option value = '"+list[i].hospitalId+"'>"+list[i].hospital+"</option>"
                    }
                    //拼接s
                    $("#hospitalId").append(s);
                }
            })
        })
        $(function () {
            $.ajax({
                url:"selectGroup",
                type:"post",
                dataType:"json",
                success:function (list) {
                    var s = "";
                    for(var i=0;i<list.length;i++){
                        s+="<option value='"+list[i].groupId+"'>"+list[i].groupClass+"</option>"
                    }
                    $("#groupId").append(s);
                }
            })
        })
        function fatherChecked() {
            //定义父选择器
            var father = $("[name=fathercheck]");
            //定义子选择器
            var children = $("[name=childrencheck]");
            //如果选中父选择器
            if(father.prop("checked")){
                //则子选择器全部循环遍历选中
                for (var i=0;i<children.length;i++){
                    //childre[i].checked = true;//js写法
                    //给子选择器选择属性赋值为true
                    $(children[i]).prop("checked",true);
                }
            }else{
                //否则未选中父选择器则遍历循环子选择器
                for(var i=0;i<children.length;i++){
                    //给子选择器选择属性赋值为false
                    $(children[i]).prop("checked",false);
                }
            }
        }

        function childrenChecked(){
            var father = $("[name=fathercheck]");
            var children = $("[name=childrencheck]");
            var bool = true;
            for(var i=0;i<children.length;i++){
                //如果子选择器没被选择 bool为false
                if(!children[i].checked){
                    bool=false;
                    break;
                }
            }
            father.prop("checked",bool);
        }
        function removeBeach() {
            //定义子选择器
            var children = $("[name=childrencheck]");
            //新建数组
            var array = new Array;
            //定义b初始值为false
            var b = false;
            //循环遍历子选择器
            for (var i = 0;i < children.length;i++) {
                //如果子选择器被选中 b为true 将子选择器的value(id值)存入到array数组中
                if (children[i].checked) {
                    b = true;
                    console.log($(children[i]).val());
                    array.push(children[i].value);
                }
            }
            //如果b为填入true
            if (b) {
                $.ajax({
                    url: "deleteGroup",
                    type: "post",
                    data: {
                        ids: array
                    },
                    dataType: "json",
					//成功返回数据data是返回的内容
                    success: function (data) {
                        if (data) {
                            alert("删除成功")
                            history.go();
                        } else alert("删除失败")
                    }
                })
            } else {
                alert("请选择要删除的数据")
            }
        }
        function exportCatalogAll() {
            window.location.href = "exportCatalogAll";
        }
	</script>
</head>
<body class="hold-transition skin-red sidebar-mini" ng-app="TbFollowVO" ng-controller="TbFollowVOController" ng-init="pages()">
<!-- .box-body -->
<toaster-container toaster-options="{'time-out': 1000,'position-class':'toast-top-center'}"></toaster-container>

<div class="box-header with-border" style="background-color: #00BFFF;color:#FFFFFF;width: 1470px">
	<h3 class="box-title">随访组分组管理</h3>
	<div class="top">
	<h5 class="setting">
		<a href="NewGroup.html" style="background-color: #00BFFF;color:#FFFFFF;">新建随访组</a>
		<a href="" style="background-color: #00BFFF;color:#FFFFFF;">随访进度管理</a>
		<a href="" style="background-color: #00BFFF;color:#FFFFFF;">数据复核</a>
		<a href="" style="background-color: #00BFFF;color:#FFFFFF;">分组管理</a>
		<a href="" style="background-color: #00BFFF;color:#FFFFFF;">系统设置</a>
		<a href="" style="background-color: #00BFFF;color:#FFFFFF;">账号设置</a>
	</h5>
</div>
</div>
<div class="box-body">
	<div class="has-feedback">
		<div style="text-align: center;padding-top: 20px;background: #ffff">
			<table class="tab">
				<tr class="col-md-6">
					<td width="100px"><span >负责人：</span></td>
					<td><input padding-center; ng-model="model.principal"></td>
				</tr>
				<tr class="col-md-6">
					<td width="100px"><span >状态：</span></td>
					<td><select padding-center; ng-model="model.state" class="form-control">
						<option value="1">开放</option>
						<option value="2">关闭</option>
					</select>
					</td>
				</tr>
				<tr class="col-md-6">
					<td width="100px"><span >科室：</span></td>
					<td>
						<select padding-center; ng-model="model.departmentId" class="form-control" id="departmentId">
							<option value="0">所有科室</option>
						</select>
					</td>
				</tr>
				<tr class="col-md-6">
					<td>创建日期:<input type="date" id="time" ng-model="model.startTime"></td>
					<td>~<input type="date" id="time2" ng-model="model.startTime"></td>
					</td>
				</tr>
			</table>
			<div style="text-align: center;padding-top: 10px">
				<button class="btn btn-default"ng-click="pages()" style="background-color: #00BFFF;color:#FFFFFF">查询</button>
			</div>
		</div>
	</div>
	<div class="box-body">
		<!-- 数据表格 -->
		<div class="table-box">
			<!-- 数据表格 -->
			<div class="table-box">
				<!--工具栏-->
				<div class="pull-left">
					<div class="form-group form-inline">
						<div class="btn-group">
							<!--onClick点击事件触发调用方法-->
							<button type="button" class="btn btn-xs" data-toggle="modal" data-target="#editModal" style="background-color: #00BFFF;color:#FFFFFF" >新建随访组</button>
							<button type="button" class="btn btn-xs" style="background-color:#00BFFF;color:#FFFFFF" onclick="removeBeach()">删除</button>
						</div>
					</div>
				</div>
			</div>
			<!--工具栏/-->
			<!--数据列表-->
			<table id="dataList" class="table table-bordered table-striped table-hover dataTable" style="background-color: #00BFFF;color:#FFFFFF">
				<thead>
				<tr>
					<th class="sorting_asc"><input type="checkbox" id="fathercheck" onclick="fatherChecked()" name="fathercheck"/></th>
					<th class="sorting_asc">序号</th>
					<th class="sorting_asc">名称</th>
					<th class="sorting_asc">负责人</th>
					<th class="sorting">状态</th>
					<th class="sorting">科室</th>
					<th class="sorting">创建日期</th>
					<th class="sorting">修改</th>
				</tr>
				</thead>
				<tbody>
				<tr ng-repeat="follow in pageUtil.result" style="color: black;background-color:whitesmoke">
					<td><input type="checkbox" id="childrencheck" onclick="childrenChecked()" ng-value="follow.id" name="childrencheck"/></td>
					<td>{{follow.id}}</td>
					<td>{{follow.followName}}</td>
					<td>{{follow.principal}}</td>
					<td>{{follow.state}}</td>
					<td>{{follow.departmentName}}</td>
					<td>{{follow.createTime | date :"yyyy-MM-dd HH:mm:ss"}}</td>
					<td>
						<button type="button" class="btn btn-xs"data-toggle="modal"data-target="#editModal1"style="background-color:#00BFFF;color:#FFFFFF;text-align:center" >
							修改
						</button>
					</td>
				</tr>
				</tbody>
			</table>
			<!--数据列表/-->
			<!--分页工具条展示-->
			<div>
				<button type="button" ng-click="pages(1)" class="btn btn-xs" style="background-color: #00BFFF;color:#FFFFFF">首页</button>
				<button type="button" ng-click="pages(pageUtil.prePage)" class="btn btn-xs" style="background-color: #00BFFF;color:#FFFFFF">上一页</button>
				<button type="button" ng-click="pages(pageUtil.nextPage)" class="btn btn-xs" style="background-color: #00BFFF;color:#FFFFFF">下一页</button>
				<button type="button" ng-click="pages(pageUtil.pages)" class="btn btn-xs" style="background-color: #00BFFF;color:#FFFFFF">尾页</button>
				<td>分页页数</td>
				<td>
					<select id="pageSize" type="text" ng-click="pages()">
						<option value="5">5</option>
						<option value="10">10</option>
						<option value="15">15</option>
						<option value="20">20</option>
					</select>
				</td>
				<td>转到</td>
				<td><input id="pagenum" type="text"style="width:42px;height:22.44px"; value="1" ng-click="pages()"/></td>
				<td><button type="button" ng-click="pages()"class="btn btn-xs" style="background-color: #00BFFF;color:#FFFFFF">GO!</button></td>
				<td>共{{pageUtil.total}}条数据</td>
			</div>
		</div>
		<!-- 数据表格 /-->
	</div>
	<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog" style="width:100%;">
			<div class="modal-content">
				<div class="modal-header">
					<button id="bt1" type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					<h3 id="myModalLabel">添加页面</h3>
				</div>
				<div class="modal-body">
					<table class="table table-bordered table-striped">
						<tr>
							<td>负责人:</td>
							<td><input ng-model="model.principal" class="form-control"></td>
							<td>名称:</td>
							<td><input ng-model="model.followName" class="form-control"></td>
							<td>电话:</td>
							<td><input ng-model="model.phone" class="form-control"></td>
							<td>课题编号:</td>
							<td><input ng-model="model.classNumber" class="form-control"></td>
							<td>患者数量:</td>
							<td><input ng-model="model.patientAmount" class="form-control"></td>
						</tr>
						<tr>
							<td>状态</td>
							<td><select ng-model="model.sex" class="form-control">
								<option value="1">开放</option>
								<option value="2">关闭</option>
							</select>
							</td>
							<td>开始时间:</td>
							<td><label for="meeting"></label><input ng-model="model.startTime" id="meeting" type="date" /></td>
							<td>结束时间:</td>
							<td><label for="meeting2"></label><input ng-model="model.endTime" id="meeting2" type="date" /></td>
							<td>医院</td>
							<td><select ng-model="model.hospitalId" class="form-control" id="hospitalId" >
							</select>
							</td>
							<td>科室</td>
							<td><select ng-model="model.departmentId" class="form-control" id="departmentId2" >
							</select>
							</td>
						</tr>
						<tr>
							<td>级别</td>
							<td><select ng-model="model.levelId" class="form-control" id="levelId" >
							</select>
							</td>
							<td>小组类别</td>
							<td><select ng-model="model.groupId" class="form-control" id="groupId" >
							</select>
							</td>
							<td>背景</td>
								<td><input padding-center; ng-model="model.background"></td>
						</tr>
					</table>
				</div>
				<div class="modal-footer">
					<button class="btn btn-success" ng-click="addGroup()"  style="background-color:#00BFFF;color:#FFFFFF">保存</button>
					<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</button>
				</div>
			</div>
		</div>
	</div>
  </div>
</body>
</html>